package com.cxf.windex.entity;

import com.cxf.windex.base.util.DateUtil;
import com.cxf.windex.enums.ActivityEnum;
import com.cxf.windex.enums.BonusTypeEnum;
import com.cxf.windex.enums.TypeEnum;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Table(name = "b_activity")
@Builder(toBuilder = true)
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@NoArgsConstructor
@Getter
@Setter
public class Activity {
    /**
     * 抵用奖ID
     */
    @Id
    private String id;

    /**
     * 活动名称
     */
    private String name;

    /**
     * 达标金额
     */
    private BigDecimal money;

    /**
     * 0认证 1充值 
     */
    private String type;

    /**
     * 适用范围 0商家 1村长
     */
    private String ranges;


    /**
     * 0固定 1百分比 
     */
    @Column(name = "bonus_type")
    private String bonusType;

    /**
     * 奖金 
     */
    private BigDecimal bonus;

    /**
     * 状态 0失效  1有效 
     */
    private String status;

    /**
     * 开始时间
     */
    @Column(name = "b_time")
    private Date bTime;

    /**
     * 结束时间
     */
    @Column(name = "e_time")
    private Date eTime;

    /**
     * 创建时间
     */
    @Column(name = "crt_time")
    private Date crtTime;

    /**
     * 创建用户IP
     */
    @Column(name = "crt_host")
    private String crtHost;


    /*-----------Transient----------------*/
    @Transient
    private String typeName;

    @Transient
    private String bonusTypeName;

    @Transient
    private String statusName;

    public void setBonusType(String bonusType) {
        this.bonusType=bonusType;
        bonusTypeName=BonusTypeEnum.keyOf(bonusType).getDesc();
    }

    public void setType(String type) {
        this.type=type;
        typeName= ActivityEnum.getIdType(type).getDesc();
    }

    public void setStatus(String status) {
        this.status = status;
        if("0".equals(status)){
            statusName="停止";
        }else {
            statusName="正常";
        }
    }
}